<?php

class SeoManager
{

    protected static $instance;
    public $title = '';
    public $description = '';
    public $keywords = '';

    private function __construct()
    {
	
    }

    private function __clone()
    {
	
    }

    private function __wakeup()
    {
	
    }

    public function setTitle($title)
    {
	$this->title = $title;
    }

    public function getTitle()
    {
	return $this->title;
    }

    public function setDescription($description)
    {
	$this->description = $description;
    }

    public function getDescription()
    {
	return $this->description;
    }

    public function setKeywords($keywords)
    {
	$this->keywords = $keywords;
    }

    public function getKeywords()
    {
	return $this->keywords;
    }

    public function set(array $data)
    {
	if (empty($data)) {
	    return;
	}
	foreach ($data as $key => $value) {
	    if (isset($this->$key)) {
		$this->$key = $value;
	    }
	}
    }

    public function render()	    
    {		
	Yii::app()->clientScript->registerMetaTag($this->getDescription(), 'description');
	Yii::app()->clientScript->registerMetaTag($this->getKeywords(), 'keywords');
	Yii::app()->getController()->setPageTitle($this->getTitle());	
    }

    public static function getInstance()
    {
	if (is_null(self::$instance)) {
	    self::$instance = new SeoManager();
	}
	return self::$instance;
    }

}